package com.arkisv.common.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

public class Springfactory implements BeanFactoryAware {

	private static BeanFactory beanFactory;

	public void setBeanFactory(BeanFactory factory) throws BeansException {
		Springfactory.beanFactory = factory;
	}

	public static <T> T getBeanForClass(Class clazz) {
        WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
        return (T) wac.getBean(clazz);
    }

}